<template>
	<view class="list page bgf6 c00">
		<view class="bgff py12 px20">
			<view class="flex flexC">
				<input class="px10 flex1 bor r40 py5" type="number" placeholder="请输入用户手机号" placeholder-class="cbe"
					v-model="mobile">
				
			</view>
			<view class="flex flexC fs12 mt12">
				<picker mode="date"   @change="dateStartChange">
					<text class="c99 w100 px12 py7 bor r40 mr10">{{startTime}}</text>
				</picker>
				<picker mode="date"   @change="dateEndChange">
					<text class="c99 w100 px12 py7 bor r40 mr10">{{endTime}}</text>
				</picker>
				<view class="aliR flex1 fs14" @click="searchList">
					<text class="bged px12 py7 r40">查询</text>
				</view>
			</view>
		</view>
		<scroll-view scroll-y="true" class="list" @scrolltolower="nextPage">
			
			<view class="bgff flex flexC flexB aliC rel r7 py20 mt16 mx12 shadow">
				<view class="flex1 borr">
					<view class="bold6 fs20">{{totalAmount}}元</view>
					<view class="c85 mb8">订单总金额</view>
				</view>
				<view class="flex1 borr">
					<view class="bold6 fs20">{{profitAmount}}元</view>
					<view class="c85 mb8">订单收益金额</view>
				</view>
			
			</view>
			
			<view v-for="item in list">


			
				<view class="bgff mx12 mt16 py20 px14">
					<view class="mb6">手机号：{{item.user.mobile}}</view>
					<view class="flex flexC mb6">
						<text class="flex1">订单金额：{{item.amount}}</text>
						<text class="flex1 ml20">订单利润：{{item.profit}}</text>
					</view>
					<view class="mb6">设备号：{{item.device_no}}</view>
					<view>订单时间：{{item.create_time_text}}</view>
				</view>
			</view>
		</scroll-view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				list: [],
				isLastPage: false,
				isnodata: false,
				totalAmount: 0,
				profitAmount: 0,
				mobile: '',
				startTime:'开始时间',
				endTime:'结束时间',

			};
		},
		onLoad(option) {

			this.getList();
		},
		methods: {
			
			dateStartChange(e){
				this.startTime = e.detail.value;
				console.info(e);
			},
			dateEndChange(e){
				this.endTime = e.detail.value;
			},
			

			searchList() {
				console.info('==mobile===' + this.mobile)
				this.page = 1;
				this.list = [];
				this.isnodata = false;
				this.isLastPage = false;
				this.getList();
			},

			nextPage() {
				if (this.isLastPage) return;
				this.page += 1;
				this.getList();
			},

			getList() {
				
				var start = this.startTime;
				if(this.startTime == '开始时间'){	
					start = "";
				}
				var end = this.endTime;
				
				if(this.endTime == '结束时间'){
					end = "";
				}
				
				let param = {
					page: this.page,
					status: this.status,
					mobile: this.mobile,
					startTime:this.start,
					endTime:this.end
				};
				let that = this;
				this.$api.lineOrderList(param).then(res => {
					if (res.code == 1) {
						let length = res.data.list.length;
						that.totalAmount = res.data.total;
						that.profitAmount = res.data.profit;
						for (let i = 0; i < length; i++) {
							that.list.push(res.data.list[i]);
						}
						if (length < 10) {
							this.isLastPage = true;
						}
						if (that.list.length > 0) {
							that.isnodata = false;
						} else {
							that.isnodata = true;
						}
					} else {

					}
				})
			},


		
		}
	}
</script>

<style lang="scss">
	.w100 {
		width: 160rpx;
	}
</style>
